import Vue from 'vue';
import Router from 'vue-router';
import Container from './router_container.vue';

Vue.use(Router);

//*******以下为添加内容*******
const VueRouterPush = Router.prototype.push;
Router.prototype.push = function push(to) {
    return VueRouterPush.call(this, to).catch((err) => err);
};
//******以上为添加内容*********

const router = new Router({
    mode: location.href.indexOf('#') > -1 ? 'hash' : 'history',
    base: '/lottery',
    routes: [
        {
            path: '/',
            redirect: { name: 'Home' },
        },
        {
            path: '/pages',
            redirect: { name: 'Home' },
            component: Container,
            children: [
                {
                    path: 'home/home',
                    name: 'Home',
                    meta: {
                        title: '首页',
                    },
                    component: (resolve) => require(['../views/pages/entry/home/home.vue'], resolve),
                },
                {
                    path: 'kaijiang/kaijiang',
                    name: 'Kaijiang',
                    meta: {
                        title: '开奖',
                    },
                    component: (resolve) => require(['../views/pages/entry/kaijiang/kaijiang.vue'], resolve),
                },
                {
                    path: 'expert/master',
                    name: 'Master',
                    meta: {
                        title: '大师精析',
                    },
                    component: (resolve) => require(['../views/pages/entry/expert/master.vue'], resolve),
                },
                {
                    path: 'expert/intelligent-recom',
                    name: 'IntelligentRecommendation',
                    meta: {
                        title: '智能推荐',
                    },
                    component: (resolve) => require(['../views/pages/entry/expert/intelligent-recom.vue'], resolve),
                },
                {
                    path: 'expert/expert',
                    name: 'Expert',
                    meta: {
                        title: '专家推荐',
                    },
                    component: (resolve) => require(['../views/pages/entry/expert/expert.vue'], resolve),
                },
                {
                    path: 'community/community',
                    name: 'Community',
                    meta: {
                        title: '社区',
                    },
                    component: (resolve) => require(['../views/pages/entry/community/community.vue'], resolve),
                },

                {
                    path: 'my/my',
                    name: 'My',
                    meta: {
                        title: '我的',
                    },
                    component: (resolve) => require(['../views/pages/entry/my/my.vue'], resolve),
                },
                {
                    path: 'home-person/home-person',
                    name: 'HomePerson',
                    meta: {
                        title: '个人主页',
                    },
                    component: (resolve) => require(['../views/pages/home-person/home-person.vue'], resolve),
                },
            ],
        },
        {
            path: '/**',
            component: (resolve) => require(['../views/components/404/404.vue'], resolve),
        },
    ],
});

export default router;
